Skip to content

Improve vector diffing#15

Open
pkoivisto wants to merge 6 commits intodaviddpark:masterfrom
pkoivisto:fix/multiple-vector-additions
Open

Improve vector diffing#15
pkoivisto wants to merge 6 commits intodaviddpark:masterfrom
pkoivisto:fix/multiple-vector-additions

Conversation

@pkoivisto
Copy link
Copy Markdown

This PR aims to primarily fix the following incorrect output reported by diff-vecs:

       (let [obj1 {"foo" []}
             obj2 {"foo" ["bar" "baz"]}
             patches [{"op" "add" "path" "/foo/0" "value" "bar"}
                      {"op" "add" "path" "/foo/1" "value" "baz"}]]
         (fact "Adding two Array Elements"
               (diff obj1 obj2) => patches))
=> 

FAIL JSON diff - Adding two Array Elements at (core_test.clj:33)
Expected:
[{"op" "add" "path" "/foo/0" "value" "bar"}
 {"op" "add" "path" "/foo/1" "value" "baz"}]
Actual:
[{"op" "replace" "path" "/foo/0" "value" "bar"}
 {"op" "add" "path" "/foo/1" "value" "baz"}]

Additionally, the diff-vecs implementation is slightly changed to improve performance for the likely common case of diff'ed vectors being the same or sharing common prefixes / suffixes.

If any changes to this PR are desired, please feel free to suggest them or just pick from this PR whatever changes you deem desirable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant